package it.amicosmanettone.finance.stocky.mysql;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;

public class UserFunctions {

	private JSONParser jsonParser;

	private static String sendMailURL = "http://www.amicosmanettone.it/api/stocky/";

	private static String sendMailBug_tag = "sendMailBug";
	private static String sendMailAdvice_tag = "sendMailAdvice";
	
	private static String post_tag = "POST";
	private static String get_tag = "GET";

	// constructor
	public UserFunctions() {
		jsonParser = new JSONParser();
	}

	public JSONObject sendMailBug(String textMessage) {

		List<NameValuePair> params = new ArrayList<NameValuePair>();
		params.add(new BasicNameValuePair("tag", sendMailBug_tag));
		params.add(new BasicNameValuePair("textMessage", textMessage));
		JSONObject json = jsonParser.getJSONFromUrl(post_tag,sendMailURL, params);

		return json;
	}

	public JSONObject sendMailAdvice(String textMessage) {

		List<NameValuePair> params = new ArrayList<NameValuePair>();
		params.add(new BasicNameValuePair("tag", sendMailAdvice_tag));
		params.add(new BasicNameValuePair("textMessage", textMessage));
		JSONObject json = jsonParser.getJSONFromUrl(post_tag,sendMailURL, params);

		return json;
	}

}